<extend name="Common/base"/>

<block name="body">
    <style>
        .cont{
            height: 60px;
            display: flex;
            align-items: center;
        }
            .cont .title.js_title{
                overflow: hidden;
                display: -webkit-box;
                white-space: pre-wrap;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
                word-break: break-all;
            }
        .nav-container{
            /*margin-bottom: -17px;*/
            height: 2.5em;
            overflow: hidden;
            border-bottom: 1px solid #eee;
        }
        .nav{
            display: flex;
            flex-wrap: nowrap;
            justify-content: space-between;
            overflow: auto;
            
            transition:all 2s;
        }
        .nav-item{
            text-align: center;
            /*border-left: 1px solid #eee;*/
            flex-basis:auto;
            flex-shrink: 0;
            flex-grow: 1;
            width: 90px;
    
    
            transition:all 2s;
        }
        .nav-item a{
            display: block;
            padding: 0 10px;
            height: 2.5em;
            line-height: 2.5em;
            text-align: center;
            background-color: #fbfbfb;
            color: #a2a2a2;
        }
        .current{
            color: #007aff !important;
        }
        ::-webkit-scrollbar{
            height: 0;
        }
    </style>
    <div class="container">
        <div id="js_plugins_loading" class="loading" style="display: none;">
            加载中    </div>
        <div id="js_plugins" style="visibility: visible;">
            <div class="slider js_plugin" id="namespace_0" data-pid="1">
                <div class="swiper-container">
                    <div class="swiper-wrapper">
    
                        <article:position type="Article" pos="2" cate="$position_category_id" child="$position_show_child" limit="6" name="article" key="key">
                            <div class="swiper-slide ">
                                <a href="{:U('Article/detail',['id'=>$article['id'],'cate'=>$article['category_id']])}">
                                    <img src="http://{:C('DOMAIN')}{$article.cover_id|get_cover='path'}" class="img noShow" style="height: 180px;float: left;">
                                    <h4 class="swiper-title">{$article.title}</h4>
                                </a>
                            </div>
                        </article:position>
                    
                    </div>
                    <!-- Add Pagination -->
                    <div class="swiper-pagination"></div>
                    <!-- Add Pagination -->
                </div>
                
                <!-- Swiper JS -->
                <script src="__JS__/swiper.min.js"></script>
                
                <!-- Initialize Swiper -->
                <script>
                    var swiper = new Swiper('.swiper-container', {
                        pagination: '.swiper-pagination',
                        paginationClickable: true,
                        nextButton: '.swiper-button-next',
                        prevButton: '.swiper-button-prev',
                        autoHeight: true, //enable auto height
                    });
                </script>
            </div>
            <div class="nav-container">
                <div class="nav">
                    <volist name="levels" id="level">
                        <div class="nav-item">
                            <a href="{:U('Article/index',['cate'=>$level['id']])}" class="<eq name='level.id' value='$current_category_id'>current</eq>" data-id="{$level.id}" data-cuid="{$current_category_id}">
                                {$level.title}
                            </a>
                        </div>
                    </volist>
                </div>
            </div>
            <div class="tab js_plugin" id="namespace_1" data-pid="2">
                
                <div class="tab_bd">
                    
                    <div class="article_list article_list_0">
                        
                        <volist name="list" id="info">
                            <a class="list_item js_post" href="{:U('Article/detail',['id'=>$info['id'],'cate'=>$info['category_id']])}" title="{$info.title}">
                                <div class="cover">
                                    <img class="img js_img noShow" src="http://{:C('DOMAIN')}{$info.cover_id|get_cover='path'}" alt="">
                                </div>
                                <div class="cont">
                                    <h2 class="title js_title">{$info.title}</h2>
                                </div>
                            </a>
                        </volist>
                    </div>
                    
                    <div class="article_list article_list_1" style="display: none;">
                    
                    </div>
                
                </div>
            </div>
        
        </div>
    </div>

    <script>
        $(function(){
            var $this = $('.nav'), $items = $('.nav .nav-item'), $width = 0, $navWidth = $this.width();
            $items.each(function(i){
                $width += $($items[i]).width();
            });
            console.log($this.scrollLeft($width - $navWidth));
            var timer = setInterval(function(){
                if ( $this.scrollLeft() <= 0 ) {
                    clearInterval(timer);
                } else {
                    $this.scrollLeft($this.scrollLeft()-1);
                }
            },2);
            
            
//            $this.scroll(function(){
//                console.log('------------Y------------');
//                var $this = $(this), $items = $this.find('.nav-item');
//                console.log($this.offset());
//                $items.each(function(i){
//                    console.log(i);
//                    var $item = $($items[i]), $offset = $item.offset();
//                    console.log($offset);
//                    console.log($item.scrollLeft());
//                    console.log($this.scrollLeft());
//                });
//                console.log('____________A____________');
//                console.log(' ');
//            });
        });
    </script>
</block>